package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FaApsDevicetype;
import com.ruoyi.system.service.IFaApsDevicetypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备类型Controller
 * 
 * @author ruoyi
 * @date 2021-09-16
 */
@RestController
@RequestMapping("/system/devicetype")
public class FaApsDevicetypeController extends BaseController
{
    @Autowired
    private IFaApsDevicetypeService faApsDevicetypeService;

    /**
     * 查询设备类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:devicetype:list')")
    @GetMapping("/list")
    public TableDataInfo list(FaApsDevicetype faApsDevicetype)
    {
        startPage();
        List<FaApsDevicetype> list = faApsDevicetypeService.selectFaApsDevicetypeList(faApsDevicetype);
        return getDataTable(list);
    }

    /**
     * 导出设备类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:devicetype:export')")
    @Log(title = "设备类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FaApsDevicetype faApsDevicetype)
    {
        List<FaApsDevicetype> list = faApsDevicetypeService.selectFaApsDevicetypeList(faApsDevicetype);
        ExcelUtil<FaApsDevicetype> util = new ExcelUtil<FaApsDevicetype>(FaApsDevicetype.class);
        return util.exportExcel(list, "设备类型数据");
    }

    /**
     * 获取设备类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:devicetype:query')")
    @GetMapping(value = "/{devicetypeId}")
    public AjaxResult getInfo(@PathVariable("devicetypeId") Integer devicetypeId)
    {
        return AjaxResult.success(faApsDevicetypeService.selectFaApsDevicetypeByDevicetypeId(devicetypeId));
    }

    /**
     * 新增设备类型
     */
    @PreAuthorize("@ss.hasPermi('system:devicetype:add')")
    @Log(title = "设备类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FaApsDevicetype faApsDevicetype)
    {
        return toAjax(faApsDevicetypeService.insertFaApsDevicetype(faApsDevicetype));
    }

    /**
     * 修改设备类型
     */
    @PreAuthorize("@ss.hasPermi('system:devicetype:edit')")
    @Log(title = "设备类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FaApsDevicetype faApsDevicetype)
    {
        return toAjax(faApsDevicetypeService.updateFaApsDevicetype(faApsDevicetype));
    }

    /**
     * 删除设备类型
     */
    @PreAuthorize("@ss.hasPermi('system:devicetype:remove')")
    @Log(title = "设备类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{devicetypeIds}")
    public AjaxResult remove(@PathVariable Integer[] devicetypeIds)
    {
        return toAjax(faApsDevicetypeService.deleteFaApsDevicetypeByDevicetypeIds(devicetypeIds));
    }
}
